package com.itheima.web;

import com.itheima.config.JdbcProperties;
import com.itheima.config.UserProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class HelloController {

    @Value("${age}")
    private Integer age;

    @Value("${user.username}")
    private String username;

    @Value("${addressList[1]}")
    private String address;

    @Autowired
    private Environment environment;

    @Autowired
    private UserProperties userProperties;

    @Autowired
    private JdbcProperties jdbcProperties;

    @GetMapping("/hello")
    public String hello(){
        /*System.out.println(age);
        System.out.println(username);
        System.out.println(address);

        System.out.println(environment.getProperty("age"));
        System.out.println(environment.getProperty("user.username"));
        System.out.println(environment.getProperty("addressList[1]"));

        System.out.println(userProperties);

        System.out.println(jdbcProperties);*/

        log.debug("记录debug信息");
        log.info("记录info信息");
        log.warn("记录warn信息");
        log.error("记录error信息");

        return "hello, springboot!";
    }
}
